package com.yhb.channel.impl.BJCJ;

import lombok.Builder;
import lombok.Data;
import org.jetbrains.annotations.NotNull;

@Data
public class BJCJRegion {
    private String province;
    private String city;
    private String area;
    private String provinceCode;
    private String cityCode;
    private String areaCode;

    public BJCJRegion(@NotNull String key, @NotNull String value) {
        String[] keys = key.split("-");
        String[] values = value.split("-");

        this.setProvince(keys[0]);
        if (keys.length == 3) {
            this.setCity(keys[1]);
            this.setArea(keys[2]);
        } else if (keys.length == 2) {
            this.setCity(keys[1]);
            this.setArea("");
        } else {
            this.setCity("");
            this.setArea("");
        }

        this.setProvinceCode(values[0]);
        this.setCityCode(values[1]);
        this.setAreaCode(values[2]);
    }
}
